# 多态
#
# class Animal:
#     def say(self):
#         print('动物的声音')
#
#
# class Person(Animal):
#     def say(self):
#         super(Person, self).say()
#         print('嘤嘤嘤')
#
#
# class Dog(Animal):
#     def say(self):
#         super(Dog, self).say()
#         print('汪汪汪')
#
#
# obj1 = Person()
# obj2 = Dog()
#
#
# def call(animal):
#     animal.say()
#
#
# call(obj1)
# call(obj2)

# 抽象基类
import abc


# 抽象动物类，强制子类实现父类函数
# 类似其他语言接口概念
class Animal(metaclass=abc.ABCMeta):
    def say(self):
        print('动物的声音')


class Person(Animal):
    def say(self):
        super(Person, self).say()
        print('嘤嘤嘤')


class Dog(Animal):
    def say(self):
        super(Dog, self).say()
        print('汪汪汪')


obj1 = Person()
obj2 = Dog()
obj3 = Animal()


def call(animal):
    animal.say()


call(obj1)
call(obj2)
